package com.cbs.java.component.database;

import com.cbs.java.component.database.mysql.MySqlDatabase;

import java.util.List;

/**
 * Created by broche on 22/08/2017.
 */
public class Main {
    public static void main(String[] args) throws Exception {
//        SqliteDatabase database = new SqliteDatabase("cache.sqlite", new MyHandler());
        MySqlDatabase database = new MySqlDatabase("192.168.1.11", "3306", "root", "Tomato.14210", "crawler");
        List<DYGang2> dyGang2s = database.query("select * from dygang", DYGang2.class);
        for (DYGang2 dyGang2 : dyGang2s) {
            System.out.println(String.format("id: %d\t\tname:%s", dyGang2.getId(), dyGang2.getName()));
        }
        DYGang2 dyGang2 = database.fetch("select * from dygang", DYGang2.class);
        System.out.println(dyGang2.getId());
    }

    private static class DYGang {
        private long id;

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    private static class DYGang2 extends DYGang {
        String url;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }
}
